import TMXarticleProvider
import subprocess
import os
import re
# TA BPO SU
if __name__ == '__main__':
    #here are the list of stocks to monitor

    def tempDir():
        if (os.path.exists(os.getenv("temp", ) + '\\quantA\\news\\') <> True):
            os.mkdir(os.getenv("temp", ) + '\\quantA\\news\\')
        return os.getenv("temp", ) + '\\quantA\\news\\'
    
    for root, dirs, files in os.walk(tempDir()):
        print files
    
    print len(files)
    
    sfile = open('slist.txt',"r") 
    slist = []
    
    slist = sfile.readlines()   
    
    #for word in slist:
    #    print word
    
    word_set = set(slist)  
        
    for f in files:    
        #print tempDir() + '\\' + f
        fp = open(tempDir() + '\\' + f, "r")
        rawtext = fp.readlines()

        txt = ''.join(rawtext)

        #print txt
        art_words = set(txt.split())
        #for word in x:
        #    art_words.add(word.split())
        
        #print word_set
        if word_set.intersection(art_words):
            print f
            subprocess.Popen('notepad '+ tempDir() + '\\' + f) 
        #print art_words
        fp.close()
        
    #subprocess.Popen('explorer '+ tempDir()) 
print 'end'

pass    